﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Practices.Unity;
using Skynet.BusinessEntities;
using Skynet.WebAdministracion.Views.CustomersMgm;

namespace Skynet.WebSite.Administracion
{
    public partial class CustomersMgmView : Infrastructure.Web.Views.Page, ICustomerMgmView
    {
        private CustomerMgmPresenter _Presenter;

        [Dependency]
        public CustomerMgmPresenter Presenter
        {
            get { return _Presenter; }
            set { 
                _Presenter = value;
                this._Presenter.View = this;
            }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            this.DetailsView1.EnableDynamicData(typeof(BusinessEntities.Customer));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.odsUsuarios.ObjectCreating += delegate(object ocds, ObjectDataSourceEventArgs args) { args.ObjectInstance = this.Presenter; };
            this.odsWorkUsuario.ObjectCreating += delegate(object ocds, ObjectDataSourceEventArgs args) { args.ObjectInstance = this.Presenter; };
            if (!Page.IsPostBack)
            {
                this.Presenter.OnViewInitialized();                
            }
            this.Presenter.OnViewLoaded();
            
        }
        protected void Page_LoadComplete(object sender, EventArgs e)
        {            
            
        }
        protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);        
            
        }

        protected void lvCustomers_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.DetailsView1.ChangeMode(DetailsViewMode.Edit); 
        }

     
    }
}